package managedBeans;

import java.sql.Connection;
import java.sql.Timestamp;
import java.util.Date;

import javaBeans.Evento;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

import dao.BdUtil;
import dao.InterconexaoDAO;

@ManagedBean
@SessionScoped
public class EventoMB {
	
	private Evento evento;
	
	public EventoMB(){

	}

	public void Gravar() {
		Date now = new Date();
		Connection vConnection = null;
		
		try {
			vConnection = BdUtil.startTransaction();
			
			evento.setUsuario_id(6);
			evento.setEvento_datacad(new Timestamp(now.getTime()));			
		
			InterconexaoDAO.criarEventoJDBC(vConnection).criar(evento);

		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace(System.out);
		}
	}
	
	public void Editar() {
		Date now = new Date();
		Connection vConnection = null;
		
		try {
			vConnection = BdUtil.startTransaction();
			
			evento.setUsuario_id(6);
			evento.setEvento_datacad(new Timestamp(now.getTime()));			
		
			InterconexaoDAO.criarEventoJDBC(vConnection).criar(evento);

		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace(System.out);
		}
	}	
	/*
	 * UTILIZADO PELO SERVLET DO JSF
	 */
	
	
	public Evento getEvento() {
		return evento;
	}


	public void setEvento(Evento evento) {
		this.evento = evento;
	}
	
}
